package easy;

public class Solution_575 {

    public int distributeCandies(int[] candyType) {
        /*boolean[] array_1 = new boolean[100001];
        boolean[] array_2 = new boolean[100001];
        int count = 0;
        int num = candyType.length / 2;
        for (int j = 0; j < candyType.length && count<num; j++) {
            int abs = Math.abs(candyType[j]);
            if (array_1[abs] || array_2[abs]) {
                continue;
            }
            count++;
            if (candyType[j] >= 0) {
                array_1[abs] = true;
            } else {
                array_2[abs] = true;
            }
        }
        return count;*/
        boolean[] array = new boolean[200001];
        int count = 0;
        int num = candyType.length / 2;
        for (int j = 0; j < candyType.length && count<num; j++) {
            int v = candyType[j] + 100000;
            if (array[v]) {
                continue;
            }
            count++;
            array[v] = true;
        }
        return count;
    }

    public static void main(String[] args) {
        Solution_575 model = new Solution_575();
        System.out.println(model.distributeCandies(new int[]{1,1,2,2,3,3}));
        System.out.println(model.distributeCandies(new int[]{1,1,2,3}));
        System.out.println(model.distributeCandies(new int[]{1, 2, 1 ,1, 1, 2}));
        System.out.println(model.distributeCandies(new int[]{100000,0,100000,0,100000,0,100000,0,100000,0,100000,0}));
        System.out.println(model.distributeCandies(new int[]{-3,0,100000,0,100000,0,100000,0,100000,0,100000,0}));
    }
}
